GOBIN		:= $(CURDIR)/bin
GOPROXY		:= https://goproxy.cn,direct
GOPRIVATE	:= gitee.com
GO111MODULE	:= on

GIT_GROUP 	:= gitee.com/tfhappy
GIT_REPO 	:= giteecli


.PHONY: test cover build deps clean

deps:
	mkdir -p $(CURDIR)/cover
	go mod tidy

# 计算测试覆盖率
cover:test
	@echo mode: count >> cover/coverage
	@tail -q -n +2 cover/*.cov >> cover/coverage
	go tool cover -html cover/coverage -o cover/coverage.html
	go tool cover -func=cover/coverage

test:
	# go test -v $(GIT_GROUP)/$(GIT_REPO)/test/core -coverprofile=cover/core1.cov -covermode=count -coverpkg=./...

build:
	go build -o $(GOBIN)/$(GIT_REPO) -ldflags "-X main.BuildTime=`date '+%Y-%m-%d_%I:%M:%S%p'` -X main.BuildGitHash=`git rev-parse HEAD` -X main.BuildGitTag=`git describe --tags 2>/dev/null || echo NO_TAG`" $(GIT_GROUP)/$(GIT_REPO)


clean:
	rm -rf bin/ cover/